
def rgb_to_rgb565(r, g, b, little_endian=True):
    """Converts RGB (0-255) values to RGB565 (16-bit) format.

    Args:
        r: Red component (0-255).
        g: Green component (0-255).
        b: Blue component (0-255).
        little_endian: True for little-endian, False for big-endian.

    Returns:
        The RGB565 value as an integer.
    """
    color = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
    return (color & 0xFF) << 8 | (color >> 8) if little_endian else color

rgb565 = rgb_to_rgb565

# Color Definitions (RGB565 format)
BLACK = rgb565(0, 0, 0)
WHITE = rgb565(255, 255, 255)
BLUE = rgb565(0, 0, 255)
RED = rgb565(255, 0, 0)
GREEN = rgb565(0, 255, 0)
CYAN = rgb565(0, 255, 255)
MAGENTA = rgb565(255, 0, 255)
YELLOW = rgb565(255, 255, 0)
ORANGE = rgb565(255, 165, 0)
PURPLE = rgb565(128, 0, 128)